package com.netease.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @projectName: modeling-dev
 * @package: com.netease.config
 * @className: Swagger2
 * @author: aochong
 * @description:
 *  原始访问路径：http://localhost:8089/swagger-ui.html
 *  bootstrap美化路径：http://localhost:8089/doc.html
 * @date: 2023/2/22 14:00
 * @version: 1.0
 */
@Configuration
@EnableSwagger2
public class Swagger2 {

    //配置Swagger2核心配置 docket
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)//指定api类型为Swagger2
                .apiInfo(apiInfo()) //用户定义api文档汇总信息
                .select().apis(RequestHandlerSelectors.basePackage("com.netease.controller")) //指定Controller包
                .paths(PathSelectors.any()) //所有Controller
                .build()
        ;
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("建模工具API文档") //文档页标题
                .contact(new Contact("netease","https://www.jianshu.com/u/651227d0778a","aochong03@crop.netease.com")) //联系人信息
                .description("专为建模工具提供的API接口文档") //详细信息
                .version("1.0.1") //文档版本号
                .termsOfServiceUrl("http://47.92.89.223:8089/doc.html") //网站地址
                .build()
                ;
    }

}
